<?php
include_once('global.php');
if($action->_islogin())					//检测是否判断
{
	header('Location:login.php');
	exit();
}
if(isset($_GET['act']) && $_GET['act'] == 'hot')
{
	$page_books = $book->_read_hot_books();
	$notnav = 1;
	$title = '图书管理&gt;&gt;热门图书列表';
}
else if(isset($_GET['action']) && $_GET['action'] == 'recyle')
{
	$page_books = $book->_read_recyle_books();
	$recyle = 'Y';
	$notnav = 1;
	$title = '图书管理&gt;&gt;文章回收站';
}
else if(isset($_POST['search_book_btn']))	//搜索图书
{
	$page_books = $book->_search_book($_POST);
	$dis = trim($_POST['search_book']);
	$title = '图书管理&gt;&gt;<font color="red">『' . $dis . '』</font>搜索结果';
	$notnav = 1;
}
else
{
	//查询所有档案（分页）
	$page_books = $book->_read_page_books();
	$total = $book->_read_count_books();
	pageft($total, DISPLAY, 1, 1, 1, 5);			//分页
	$title = '图书管理&gt;&gt;所有图书列表';
}

//进入编辑文章页面
if(isset($_GET['action']) && $_GET['action'] == 'edit')
{
	$edit   = $_GET['tbid'];
	//读取单条数据
	$result = $book->_read_a_books($edit);
	//读取分类
	$class = $book->_read_class();
	$title  = '图书管理&gt;&gt;编辑图书信息';
}
//执行编辑文章功能
if(isset($_POST['edit_submit']))
{
	$book->_edit_books($_POST);
}
//查看文章
if(isset($_GET['action']) && $_GET['action'] == 'look')
{
	$look   = $_GET['tbid'];
	//读取单条数据
	$result = $book->_read_a_books($look);
	$title  = '图书管理&gt;&gt;查看图书信息';
}
//添加文章
if(isset($_GET['action']) && $_GET['action'] == 'add')
{
	$bk_add = 1;
	//读取分类
	$class = $book->_read_class();
	$title  = '图书管理&gt;&gt;添加图书';
}
if(isset($_POST['books_add_sub']))			//添加动作
{
	$book->_add_books($_POST);
}
//进入回收站页面
if(isset($_GET['action']) && $_GET['action'] == 'del')
{
	$book->_del_books($_GET['tbid']);	
}
if(isset($_GET['action']) && $_GET['action'] == 'recyle_back')	//恢复
{
	$book->_back_books($_GET['tbid']);
}
if(isset($_GET['action']) && $_GET['action'] == 'recyle_del')
{
	$book->_clean_books($_GET['tbid']);
}
include('templates/books_main.html');
?>